package com.itany.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

/**
 * Author：汤小洋
 * Date：2022-11-21 10:20
 * Description：<描述>
 */
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("HelloServlet.service.........................");

        req.setAttribute("name","tom");

        List<String> hobbies = Arrays.asList("eat","sleep","doudou");
        req.setAttribute("hobbies",hobbies);

        Properties p = new Properties();
        p.load(HelloServlet.class.getClassLoader().getResourceAsStream("datasource.properties"));
        System.out.println(p);

        req.getRequestDispatcher("/index.jsp").forward(req,resp);
    }
}
